package com.cuit.controller;

import com.cuit.pojo.Doctor;
import com.cuit.pojo.DoctorOrder;
import com.cuit.service.D_OrderService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/doctor_cm/order/orderdate")
public class d_OrderDataServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Doctor d2=(Doctor)request.getSession().getAttribute("doc");
        String[] das=request.getParameterValues("date");
        int da[]=new int[das.length];
        int maxs[]=(int[])request.getSession().getAttribute("maxs");
        for(int i=0;i<das.length;i++){
            da[i]=Integer.parseInt(das[i]);
            maxs[da[i]-1]=Integer.parseInt(request.getParameter("morder"));
        }
        DoctorOrder or=new DoctorOrder(Integer.parseInt(request.getParameter("morder")),
                d2.getId(),da);
        D_OrderService os=new D_OrderService(or);
        os.uptaM();
        request.getSession().setAttribute("maxs",maxs);
        response.sendRedirect("/hospital/doctor_cm/order/d_order_date.jsp");
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
